package ${rootPkg}.controller;

import ${rootPkg}.entity.${bClassName};
import ${rootPkg}.fegin.${bClassName}Fegin;
import ${rootPkg}.service.I${bClassName}Service;
import com.unbox.common.response.UnboxResponse;
import com.unbox.common.table.UnBoxPage;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RestController;
import java.util.List;

/**
 * <p>
 * <${tableComment}业务Controller
 * </p>
 *
 * @author 王振宇
 * @since ${.now?string('yyyy-MM-dd')}
 */
@Api(tags = "${tableComment}管理api")
@RestController
public class ${bClassName}Controller implements ${bClassName}Fegin {

    @Autowired
    I${bClassName}Service ${sClassName}Service;

    /**
     * 分页查询
     * @param ${sClassName}
     * @return
     */
    @ApiOperation(value = "分页查询列表")
    @Override
    public UnboxResponse<UnBoxPage> getPageList(${bClassName} ${sClassName}, Integer pageNo, Integer pageSize) {
        UnBoxPage page = ${sClassName}Service.getPageList(${sClassName},pageNo, pageSize);
        return new UnboxResponse<>(page);
    }

    /**
     * 查询列表
     *
     * @param ${sClassName}
     * @return
     */
    @Override
    public UnboxResponse<List<${bClassName}>> getList(${bClassName} ${sClassName}) {
        List<${bClassName}> datas = ${sClassName}Service.getList(${sClassName});
        return new UnboxResponse<>(datas);
    }

    /**
     * 详情
     * @param ${sClassName}
     * @return
     */
    @ApiOperation(value = "查询明细")
    @Override
    public UnboxResponse<${bClassName}> info(${bClassName} ${sClassName}) {
        ${bClassName} ${sClassName}Vo = ${sClassName}Service.get(${sClassName});
        return new UnboxResponse<>(${sClassName}Vo);
    }

    /**
     * 通过id数据查询数据
     * @param ids
     * @return
     */
    @ApiOperation(value = "通过ids进行in查询")
    @Override
    public UnboxResponse<List<${bClassName}>> ids${bClassName}s(List<Integer> ids) {
        List<${bClassName}> ${sClassName}s = ${sClassName}Service.getIdsList(ids);
        return new UnboxResponse<>(${sClassName}s);
    }

    /**
     * 保存数据
     * @param ${sClassName}
     * @return
     */
    @ApiOperation(value = "保存数据")
    @Override
    public UnboxResponse<Boolean> save(${bClassName} ${sClassName}) {
        Boolean flg = ${sClassName}Service.save(${sClassName});
        return new UnboxResponse<>(flg);
    }

    /**
     * 批量添加
     * @param ${sClassName}s
     * @return
     */
    @ApiOperation(value = "批量保存数据")
    @Override
    public UnboxResponse<Boolean> batchSave(List<${bClassName}> ${sClassName}s) {
        Boolean flg = ${sClassName}Service.saveBatch(${sClassName}s);
        return new UnboxResponse<>(flg);
    }

    /**
     * 修改数据
     * @param ${sClassName}
     * @return
     */
    @ApiOperation(value = "修改数据")
    @Override
    public UnboxResponse<Boolean> update(${bClassName} ${sClassName}) {
        Boolean flg = ${sClassName}Service.update(${sClassName});
        return new UnboxResponse<>(flg);
    }

    /**
     * 批量修改
     * @param ${sClassName}s
     * @return
     */
    @ApiOperation(value = "批量修改数据")
    @Override
    public UnboxResponse<Boolean> batchUpdate(List<${bClassName}> ${sClassName}s) {
        Boolean flg = ${sClassName}Service.updateBatchById(${sClassName}s);
        return new UnboxResponse<>(flg);
    }

    /**
     * 删除数据
     * @param ${sClassName}
     * @return
     */
    @ApiOperation(value = "删除数据")
    @Override
    public UnboxResponse<Boolean> delete(${bClassName} ${sClassName}) {
        Boolean flg = ${sClassName}Service.remove(${sClassName});
        return new UnboxResponse<>(flg);
    }

    /**
     * 批量删除
     * @param ids
     * @return
     */
    @ApiOperation(value = "批量删除")
    @Override
    public UnboxResponse<Boolean> deleteBatch(List<Integer> ids) {
        Boolean flg = ${sClassName}Service.removeByIds(ids);
        return new UnboxResponse<>(flg);
    }
}

